Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated EPS mode when opening images without transparency #8281

Merged
merged 14 commits into from
Oct 6, 2024

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Aug 3, 2024

  1. I moved all EPS images (and images converted from EPS images) to their own folder so that they're all together.
  2. I noticed that 1.eps has a BoundingBox of (72, 48), but its ImageData says its size is (100, 67). Pillow currently believes the image size should be (100, 67), so I've added a BMP version of this image at that size to compare it to. However, this comparison does not currently work, because an error occurs when calling Image.tobytes() on the EPS image.

ValueError: No packer found from RGB to 1

@Yay295
Copy link
Contributor Author

Yay295 commented Aug 3, 2024

I tried converting "1.eps" to PNG using ImageMagick, and it converted it to a 72x48 sized image. So perhaps Pillow isn't using the right size either. Not that there necessarily is a "right" size, since EPS isn't a raster image format.

@Yay295
Copy link
Contributor Author

Yay295 commented Aug 3, 2024

Mode "1" and "L" images should now load as those modes instead of being converted to RGB. "LAB" and "CMYK" are still converted to RGB though.

@Yay295 Yay295 marked this pull request as ready for review August 3, 2024 23:55
@radarhere
Copy link
Member

I tried converting "1.eps" to PNG using ImageMagick, and it converted it to a 72x48 sized image. So perhaps Pillow isn't using the right size either. Not that there necessarily is a "right" size, since EPS isn't a raster image format.

This is reverting the change requested in #6382 (comment). I'm reluctant to change how Pillow behaves again just because a different third-party application was chosen to compare this against?

@Yay295
Copy link
Contributor Author

Yay295 commented Aug 4, 2024

I used ImageMagick because I don't have Photoshop, but I would consider Photoshop to be the one to follow, since EPS is an Adobe creation. I'll remove that commit.

src/PIL/EpsImagePlugin.py Outdated Show resolved Hide resolved
@radarhere radarhere changed the title Test 1.eps size and data Updated EPS mode and size after opening Sep 30, 2024
src/PIL/EpsImagePlugin.py Outdated Show resolved Hide resolved
src/PIL/EpsImagePlugin.py Outdated Show resolved Hide resolved
Yay295 and others added 2 commits October 1, 2024 09:33
Co-authored-by: Andrew Murray <[email protected]>
Co-authored-by: Andrew Murray <[email protected]>
@radarhere radarhere changed the title Updated EPS mode and size after opening Updated EPS mode after opening for images without transparency Oct 5, 2024
Tests/test_file_eps.py Outdated Show resolved Hide resolved
Copy link
Member

@radarhere radarhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My list of the changes in this PR.

  1. Raise an error if the "BoundingBox" is absent, even if "ImageData" is present
  2. Fix loading images where "BoundingBox" occurs after "ImageData"
  3. For images without transparency, automatically pick 1, L or RGB mode

@radarhere radarhere changed the title Updated EPS mode after opening for images without transparency Updated EPS mode when opening images without transparency Oct 5, 2024
@hugovk hugovk merged commit 96f1a6e into python-pillow:main Oct 6, 2024
48 checks passed
@Yay295 Yay295 deleted the eps_test branch October 6, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants